package com.springapp.model;

import java.io.Serializable;
import java.util.jar.Attributes.Name;

import javax.persistence.AttributeOverride;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.google.gson.annotations.Expose;

/*
 * 
 * @uthor Sim4ik
 */
@Entity
@Table(name = "ITEM")
@AttributeOverride(name = "name", column = @Column(name = "ITEM_NAME"))
public class Item extends NameEntity implements Serializable {
	
	
	@ManyToOne
	@JoinColumn(name = "CATEGORY_ID")
	private Cathegory cathegory;

	@Column(name = "ITEM_PRICE")
	private Double price;
	
	@Column(name = "ITEM_DESCRIPTION")
	private String description;

	public Item () {}
	
	public Cathegory getCathegory() {
		return cathegory;
	}

	public void setCathegory(Cathegory cathegory) {
		this.cathegory = cathegory;
	}

	public Double getPrice() {
		return price;
	}

	public void setPrice(Double price) {
		this.price = price;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result
				+ ((cathegory == null) ? 0 : cathegory.hashCode());
		result = prime * result
				+ ((description == null) ? 0 : description.hashCode());
		result = prime * result + ((price == null) ? 0 : price.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		Item other = (Item) obj;
		if (cathegory == null) {
			if (other.cathegory != null)
				return false;
		} else if (!cathegory.equals(other.cathegory))
			return false;
		if (description == null) {
			if (other.description != null)
				return false;
		} else if (!description.equals(other.description))
			return false;
		if (price == null) {
			if (other.price != null)
				return false;
		} else if (!price.equals(other.price))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Item [cathegory=" + cathegory + ", price=" + price + "]";
	}

}
